﻿using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace RandomSelectTool.Resources.Components.ViewModel
{
    internal class StudentClassModel : INotifyPropertyChanged
    {
        private Dictionary<(DayOfWeek, int), string> _schedule; // 课程表数据

        public event PropertyChangedEventHandler PropertyChanged;

        public StudentClassModel()
        {
            _schedule = new Dictionary<(DayOfWeek, int), string>();
        }

        // 设置课程
        public void SetCourse(DayOfWeek dayOfWeek, int period, string course)
        {
            _schedule[(dayOfWeek, period)] = course;
            OnPropertyChanged(nameof(Schedule));
        }

        // 获取课程
        public string GetCourse(DayOfWeek dayOfWeek, int period)
        {
            if (_schedule.TryGetValue((dayOfWeek, period), out string course))
            {
                return course;
            }
            return null;
        }

        // 课程表数据
        public Dictionary<(DayOfWeek, int), string> Schedule
        {
            get { return _schedule; }
            set
            {
                _schedule = value;
                OnPropertyChanged(nameof(Schedule));
            }
        }

        // 属性更改通知
        private void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
